/*
 * Edge.java
 *
 * Created on 4 de enero de 2007, 09:27 AM
 */

package networkFlow;

/**
 *
 * @author tavobula
 */
public class Edge  {
    
    /** Creates a new instance of Edge */
    private int pv,pw,pcap, pflow, pcost;
    public static int M=20000,C=10000;
    
    public Edge(int v, int w, int cap){
        this.pv=v;
        this.pw=w;
        this.pcap=cap;
        this.pflow=0;
    }
    
    public Edge(int v, int w, int cap, int cost, int flow){
        this.pv=v;
        this.pw=w;
        this.pcap=cap;
        this.pcost=cost;
        this.pflow=flow;
    }
    
   public Edge(int v, int w, int cap, int flow){
        this.pv=v;
        this.pw=w;
        this.pcap=cap;
        this.pflow=flow;
    }
 
    
    public int getV(){
        return pv;
    }
    
    public int getW(){
        return pw;
    }
    
    public int getPcap(){
        return pcap;
    }
    
    public int getPflow(){
        return pflow;
    }
    
    public boolean from(int v){
       return pv==v;
    }
    
    public int other(int v){
        return from(v)?pw:pv;
    }
    
    public int capRto(int v){
        return from(v)?pflow:pcap-pflow;
    }
    
    public void addflowRto(int v, int d){
        pflow+=from(v)?-d:d;
    }
    
    public int cost(){
        return pcost;
    }
    
    public int costRto(int v){
        return from(v)?-pcost:pcost;
    }
    
    public String toString(){
        String s=this.getV()+"\t"+this.getW()+"\t("+this.pflow+")";
        return s;
    }
    
}
